<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">

							<li>
								<label class="col-sm-12 control-label" >选择测试用例：</label>
							</li>

							<li>
								<div class="col-sm-12" style="width: 200px">

									<select id="caseId" name="caseId" class="form-control m-b"  style="padding-right: 20px">
										<option value="" >请选择</option>
										<option th:each="item:${cases}" th:text="${item.caseName}" th:value="${item.id}" ></option>
									</select>
								</div>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="jmeter:jmeterAlertConfig:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="jmeter:jmeterAlertConfig:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="jmeter:jmeterAlertConfig:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="jmeter:jmeterAlertConfig:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
	 <script th:src="@{/ajax/libs/select/select2.js}"></script>
	 <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('jmeter:jmeterAlertConfig:edit')}]];
        var removeFlag = [[${@permission.hasPermi('jmeter:jmeterAlertConfig:remove')}]];
        var prefix = ctx + "jmeter/jmeterAlertConfig";

        $(function() {

			$("#caseId").select2();

			let caseId=[[${caseId}]];
			if(caseId!=null && caseId!=undefined){
				$("#caseId").val( [[${caseId}]]).change();
			}

            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "告警配置",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : 'id',
					visible: false
				},
				{
					field : 'caseName', 
					title : '用例名称',
					sortable: true
				},
				{
					field : 'threadThreshold', 
					title : '并发数阈值',
					sortable: true
				},
				{
					field : 'status', 
					title : '状态',
					formatter: function (value) {
						if (value == 1) {
							var hdiv = '<span  class="glyphicon glyphicon-ok-sign" style="color: rgb(0, 175, 0);"> 启用</span>';
						} else if (value == 0) {
							var hdiv = '<span  class="glyphicon glyphicon-minus-sign" style="color: rgba(10,7,21,0.98);"> 禁用</span>';
						}
						return '<font id="statusFont">' + hdiv + '</font>';
					}
				},
				{
					field : 'tps', 
					title : 'TPS阈值',
					sortable: true
				},
				{
					field : 'successRatio', 
					title : '成功率',
					formatter: function (value) {
						return value+"%";
					}
				},
				{
					field : 'avgRespTime', 
					title : '平均响应时间',
					formatter: function (value) {
						return value+"(ms)";
					}
				},
				{
					field : 'line95', 
					title : '95line时间',
					formatter: function (value) {
						return value+"(ms)";
					}
				},
				{
					field : 'createTime', 
					title : '创建时间',
					formatter: function (value,
										 row, index) {
						return $.common.formatTime(value);
					}
				},
				{
					field : 'updateTime', 
					title : '修改时间',
					formatter: function (value,
										 row, index) {
						return $.common.formatTime(value);
					}
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
			$.table.search();
		});
    </script>
</body>
</html>